Use getattr instead of a stupid if