properly handle nested classes