A compound of formula wherein: X and X 1 are independently CR 4 or N; Y and Y 1 are independently C or N; Z and Z 1 are independently CR 6, NR 7, N, O or S; R 1 and R 2 are independently selected from hydrogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -haloalkyl, C 1 -C 7 -alkoxy-C 1 -C 7 -alkyl, heterocycloalkyl or C 1 -C 7 -alkyl optionally substituted by aryl or heteroaryl or R 1 and R 2, together with the nitrogen atom to which they are attached, form a bicyclic ring system or a heterocycloalkyl which can be substituted by 1 to 3 substituents independently selected from the group consisting of hydroxyl, halogen, C 1 -C 7 -alkyl, C 1 -C 7 - alkoxy, C 1 -C 7 -haloalkyl and oxo; R 3 is hydrogen or C 1 -C 7 -alkyl; R 4 is hydrogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -haloalkyl or halogen; R 5 is aryl or heteroaryl both groups optionally substituted by C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, halogen, C 1 -C 7 -haloalkyl, C 1 -C 7 -alkoxy, hydroxyl, C 1 -C 7 -hydroxyalkyl, C 1 -C 7 -alkoxyalkyl, acetyl, cyano, amino optionally substituted by one or two C 1 -C 7 -alkyl groups; R 6 is hydrogen, halogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -alkoxy, C 1 -C 7 - haloalkyl, C 1 -C 7 -alkoxyalkyl, heterocycloalkyl, aryl, heteroaryl, or C 1 -C 7 -alkyl optionally substituted by aryl, heteroaryl, heterocycloalkyl, cycloalkyl or R 5 and R 6, together with the Y 1 and Z atom to which they are attachted, form aryl or heteroaryl both groups optionally substituted by C 1 -C 7 alkyl, halogen, C 1 -C 7 -alkoxy, C 1 -C 7 -haloalkyl; R 7 is hydrogen, halogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -alkoxy, C 1 -C 7 - haloalkyl, C 1 -C 7 -alkoxyalkyl, heterocycloalkyl, aryl, heteroaryl, or C 1 -C 7 -alkyl optionally substituted by aryl, heteroaryl, heterocycloalkyl, cycloalkyl or R 5 and R 7, together with the Y 1 and Z atom to which they are attachted, form aryl or heteroaryl both groups optionally substituted by C 1 -C 7 alkyl, halogen, C 1 -C 7 -alkoxy, C 1 -C 7 -haloalkyl; W is selected from ethylene, ethenylene both optionally substituted by C 1 -C 7 alkyl or halogen or W is -N=CH-. X and X 1 are independently CR 4 or N; Y and Y 1 are independently C or N; Z and Z 1 are independently CR 6, NR 7, N, O or S; R 1 and R 2 are independently selected from hydrogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -haloalkyl, C 1 -C 7 -alkoxy-C 1 -C 7 -alkyl, heterocycloalkyl or C 1 -C 7 -alkyl optionally substituted by aryl or heteroaryl or R 1 and R 2, together with the nitrogen atom to which they are attached, form a bicyclic ring system or a heterocycloalkyl which can be substituted by 1 to 3 substituents independently selected from the group consisting of hydroxyl, halogen, C 1 -C 7 -alkyl, C 1 -C 7 - alkoxy, C 1 -C 7 -haloalkyl and oxo; R 3 is hydrogen or C 1 -C 7 -alkyl; R 4 is hydrogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -haloalkyl or halogen; R 5 is aryl or heteroaryl both groups optionally substituted by C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, halogen, C 1 -C 7 -haloalkyl, C 1 -C 7 -alkoxy, hydroxyl, C 1 -C 7 -hydroxyalkyl, C 1 -C 7 -alkoxyalkyl, acetyl, cyano, amino optionally substituted by one or two C 1 -C 7 -alkyl groups; R 6 is hydrogen, halogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -alkoxy, C 1 -C 7 - haloalkyl, C 1 -C 7 -alkoxyalkyl, heterocycloalkyl, aryl, heteroaryl, or C 1 -C 7 -alkyl optionally substituted by aryl, heteroaryl, heterocycloalkyl, cycloalkyl or R 5 and R 6, together with the Y 1 and Z atom to which they are attachted, form aryl or heteroaryl both groups optionally substituted by C 1 -C 7 alkyl, halogen, C 1 -C 7 -alkoxy, C 1 -C 7 -haloalkyl; R 7 is hydrogen, halogen, C 1 -C 7 -alkyl, C 3 -C 8 -cycloalkyl, C 1 -C 7 -alkoxy, C 1 -C 7 - haloalkyl, C 1 -C 7 -alkoxyalkyl, heterocycloalkyl, aryl, heteroaryl, or C 1 -C 7 -alkyl optionally substituted by aryl, heteroaryl, heterocycloalkyl, cycloalkyl or R 5 and R 7, together with the Y 1 and Z atom to which they are attachted, form aryl or heteroaryl both groups optionally substituted by C 1 -C 7 alkyl, halogen, C 1 -C 7 -alkoxy, C 1 -C 7 -haloalkyl; W is selected from ethylene, ethenylene both optionally substituted by C 1 -C 7 alkyl or halogen or W is -N=CH-.