Eliminate repeated code