implemented backward tracking
added test for backward tracking