added rename function and bug fix