converted code to be an object

so it is in it's own 'namespace'
added some documentation