Divided up functionality into functions