Add try finally to close connection