moving around functions and adding comments - no functionalist changes