adding eppstein's code