Vastly improved implementation!!