move editing logic out of shell file