worked out all issue.. but no solutions..
either i have some logic problem with this backtrace method or there is some mistake in my code that prevents the solution from being found.