applied closure patttern for client.js