Modified ED function