moved all 'private' methods inside the closure