order of ops almost working correctly
i think it works now...