Cleaned up duplicate code.