refactoring the code to work with Decimal instead of BigDecimal