fixed a minor bug: result variable was being set before checking to see if any results were returned