moved more functions into closure