implemented all algorithms