rewrite the function: check_user