Improved the pump algorithm