Switched to built in \mod function

Looks weird in places because it adds whitespace to the left, so I have taken out brackets around some parts to reduce this weirdness