Moving code into procedures
(not working) more stuff