improve algorithm for life mode