algorithm handles rain