fixed regenerate capsules function