Refactor the code for weather determination