Implemented logging, and removed the debug print statements