Use block to manage closing connection