Perfect maze reimplemented