Fixed math bug