made modifications and added comments