How to auto identify range, fee and rate then calculate total