fixing math bug