Refactoring SQL executor

Refactored the code area responsible for displaying results when non empty rows are returned from the executed query.