working on puzzle solving optimization