next logic