simplify get_calculated_columns & remove duplicate code