refactor classes to algorithm package