Use quotRem instead of div and mod to increase performance