simplified the memory usage on a solution
changed few modules to more pythonic-3