small changes to generating distance