fix phase change logic