refactor comment creation code