Fixed issue with isDefined being called on the wrong object