Moved two functions into seperate files