Clean up duplicate code