modified int_sqrt