ammendments to backtrack.py