refactor __getattr__ a bit