fix bugs on deleting and creating