Eliminate some repetitive code