encapsulate everything in closure