Implemented pruning
improved algorithm logic
improved output