fixed some bugs and added onblur and onfocus handlers