fixed some bugs and added alert messages