simplified + exploded getattr logic to be more readable.