#6 rewritten in Julia