Removed original implementation that I broke and couldn't fix, replaced with new implementation and double function templates