Fixed bugs in main and refactored log file to take in a path