Fixing modulo and increment for login mode