reimplement discount calculation with formula