make the main func more concise