fix flag reference and use helper to clean up name