fixed miscalculation of profit, and converted values to int where necessary