more refactoring to simplify code and fixed summary edit bug