Simplify code of getting names.