added errorhandling if queryresult is null