Bug fix when layer query fails