refactored regenerate method #68