cleanup, duplicate code moved in separate method