added comments, need to figure out the js, though