upgraded some fuctions