move the check to the match block