maze refactoring (broken!)