Added logic to check for query string parameters before making SQL calls