Remove some repetitive code