cleaned up math