added new function and bug solved