added code to find D