corrected check function