First version with Backtracking Monad