Optimizing move generation