Majo rewrite into a better solution, closer to stdlib