multiple updates
added many comments and simplification of code