revised and added comments