Math conditions not calculating correctly