added new funcs and fixed some mistakes