fixed NPE exceptions for dynamic elements