Refactored Code - todo: connection no terminating after request