math calculations and conditions no longer working