Split file into functions to make adding new features easier.