Made the recursive program a bit simpler