updated code, added some docblocks