added mising local var declaration
added type check for dynamically created guards