A compound of formula: and pharmaceutically acceptable salts thereof, wherein X = CH or N R 1 represents C 3-10 cycloalkyl, C 6-10 aryl and C 5-10 heterocyclyl, said cycloalkyl, aryl and heterocyclyl optionally substituted with 1 to 3 groups of R a, R2 and R2a independently represent H, and C 1-6 alkyl, said alkyl optionally substituted with 1 to 3 groups of R a, or R 2 and R 2a together with the nitrogen to which they are attached combined to form a C 3-10 heterocyclic ring wherein 1 to 2 carbon atoms on the ring are optionally interrupted by 1 to 2 heteroatoms selected from N, O and S, said heterocyclic ring optionally substituted with 1 to 3 groups of R a, R 3 and R 4 independently represent: hydrogen, -C 1-6 alkyl, optionally substituted with 1 to 3 groups of R a, C 3-10 cycloalkyl, C OR 3, or R 3 and R 4 can combine with the atom to which they are attached to form a 3 to 6 spirocyclalkyl ring, R a represents: hydroxyl, halogen, C 1-6 alkyl, (CH 2) n C 6-10 aryl, which is unsubstituted or substituted with 1 to 3 groups of Rb, (CH 2) n heterocyclyl, which is unsubstituted or substituted with 1 to 3 groups of R b, and -CN, -O (CH 2) n C 1-4 haloalkyl, COOR 3, C 3-10 cycloalkyl, C C 1-6 alkyl, S 2 C 1-6 alkyl, C 2-4 alkynyl, C 2-4 alkenyl, and 2 or more adjacent R a 's may combine with the atoms to which they are attached to form a 3-10 carbocyclic ring with 1 to 2 carbons atoms on the ring optionally interrupted by 1 to 2 heteroatoms selected from N, O, and S, wherein said alkyl, aryl, heterocyclyl, cycloalkyl, alkynyl, alkenyl, and carbocyclic ring are optionally substituted with 1 to 3 groups of Rb, R b represents: hydroxyl, halogen, C 1-6 alkyl, and C 1-4 haloalkyl, -OC 1-6 alkyl, C 3-10 cycloalkyl, C 2-6 alkenyl, and S 2 C 1-6 alkyl, n is 0-4. X = CH or N R 1 represents C 3-10 cycloalkyl, C 6-10 aryl and C 5-10 heterocyclyl, said cycloalkyl, aryl and heterocyclyl optionally substituted with 1 to 3 groups of R a, R2 and R2a independently represent H, and C 1-6 alkyl, said alkyl optionally substituted with 1 to 3 groups of R a, or R 2 and R 2a together with the nitrogen to which they are attached combined to form a C 3-10 heterocyclic ring wherein 1 to 2 carbon atoms on the ring are optionally interrupted by 1 to 2 heteroatoms selected from N, O and S, said heterocyclic ring optionally substituted with 1 to 3 groups of R a, R 3 and R 4 independently represent: hydrogen, -C 1-6 alkyl, optionally substituted with 1 to 3 groups of R a, C 3-10 cycloalkyl, C OR 3, hydrogen, -C 1-6 alkyl, optionally substituted with 1 to 3 groups of R a, C 3-10 cycloalkyl, C OR 3, or R 3 and R 4 can combine with the atom to which they are attached to form a 3 to 6 spirocyclalkyl ring, R a represents: hydroxyl, halogen, C 1-6 alkyl, (CH 2) n C 6-10 aryl, which is unsubstituted or substituted with 1 to 3 groups of Rb, (CH 2) n heterocyclyl, which is unsubstituted or substituted with 1 to 3 groups of R b, and -CN, -O (CH 2) n C 1-4 haloalkyl, COOR 3, C 3-10 cycloalkyl, C C 1-6 alkyl, S 2 C 1-6 alkyl, C 2-4 alkynyl, C 2-4 alkenyl, and 2 or more adjacent R a 's may combine with the atoms to which they are attached to form a 3-10 carbocyclic ring with 1 to 2 carbons atoms on the ring optionally interrupted by 1 to 2 heteroatoms selected from N, O, and S, wherein said alkyl, aryl, heterocyclyl, cycloalkyl, alkynyl, alkenyl, and carbocyclic ring are optionally substituted with 1 to 3 groups of Rb, hydroxyl, halogen, C 1-6 alkyl, (CH 2) n C 6-10 aryl, which is unsubstituted or substituted with 1 to 3 groups of Rb, (CH 2) n heterocyclyl, which is unsubstituted or substituted with 1 to 3 groups of R b, and -CN, -O (CH 2) n C 1-4 haloalkyl, COOR 3, C 3-10 cycloalkyl, C C 1-6 alkyl, S 2 C 1-6 alkyl, C 2-4 alkynyl, C 2-4 alkenyl, and 2 or more adjacent R a 's may combine with the atoms to which they are attached to form a 3-10 carbocyclic ring with 1 to 2 carbons atoms on the ring optionally interrupted by 1 to 2 heteroatoms selected from N, O, and S, R b represents: hydroxyl, halogen, C 1-6 alkyl, and C 1-4 haloalkyl, -OC 1-6 alkyl, C 3-10 cycloalkyl, C 2-6 alkenyl, and S 2 C 1-6 alkyl, hydroxyl, halogen, C 1-6 alkyl, and C 1-4 haloalkyl, -OC 1-6 alkyl, C 3-10 cycloalkyl, C 2-6 alkenyl, and S 2 C 1-6 alkyl, n is 0-4.