Changed bin calculation to standard math