use unless condition and avoid using next