uses hasattr instead of try,catch