redid the fuction, other way was not working right