Move user check to a subfunction