Refactoring SQL executor

I have refactored sql executor further using the extract method.