Tidying up the code before making it dynamic