Maybe put this into an else clause in the "if hasattr" below?