fixed ptr bug, added comments