Minor fixes in logic and handling empty request vars

Renamed some variables and handles some edge conditions - like no results