fixing order of operations