coding done. fixed some bugs