* added query function
* reorganized event handling with delegation