Improved Algorithm, testing remaining