Optimized scanformoves function