version 1 -- added comments and cleaned up