better fix for the fact that getsingleresult throws an error when no result. We want to return null and that's what this function does.