Fixed order of operations bug