Fixed order of operations

Some of the operations were out of order.