Modified code to fix the assessorial markup amount bug. The variable $ass_cost was being redefined only if $cost had a value. Else it would take value from previous run of the subroutine.
Now $ass_cost gets redefined every time the subroutine is called.