clean up duplicate code