working. added comments