improve readability in data_by method