cleaner implementation for row-object function