a little math optimization