completed major functions, bugtesting and fixing