added code for d and e