Refactor to functions for modularity
Renamed main program file