Added a second gm function to clarify the operations. Changed layout of ops to clarify function.