trials: backtracking solution implemented