hasattr did not work, replaced with try