modifications and fine tuning by DP :cop: