bug with some math corrected