fixed a few bugs and added popup alert functionality