validation added and many bugs fixed