Simplified some repetitive code