Replaced mod() with remainder()