Removed aforementioned spaghetti state monad code, it's now just recursion