rewrote getattr to be function-based

removed nested try/except tree and replaced it with subfunctions.