adding funcatinoality and fixed bugs