add a close button and cleanup javascript