fixed math bug