implemented find solution algorithm