code cleanup and separating out edit actions