Optimized marker finding  algorithm