Fixed registration by handling empty query results