fix "object has no attribute" error