new object based approach, modified dialog.js