Made handle much more efficient and non-recursive