moved certain things to their own functions to clean up main part of creating task