Eliminate code repetition here