Added #where; refactored more