move check to a proper place