Factor that looong 'if' into one function per operation (add etc.)