logic problems resolved, math working