Reduced some repetition of code