restructured the code in two separate files