changed location of check variable