Minor code refactoring to reduce code while maintaining same functionality.