made the algorithms a little more general