single if and cleaner code