split up the code into seperate functions