Fixed onclick handler for button and defined new scope function