improve algorithm for marking as solved