fixed loop detection
started writing backward algorithm description