further removal of duplicate code