Refactored: mod to signAwareModulo; reached consistent pattern-matching style