replaced geattr with hasattr