add valid puzzle check. Logic still not perfect.