added comments and docs