reorganize and single-line a function