Fixed Bugs and tested