A compound of formula: or a pharmaceutically acceptable salt thereof, wherein X is CH 2, Y is selected from CH 2, O or S 2; or X and Y together with the bond there-between form -CH=CH- or -C≡C-; G is N or CH; R 1 is aryl or heteroaryl, each of which is optionally substituted with one or more substituents independently selected from halo, -NR 6 R 7, -OR 8, -S n R 9, -(CH 2) r -C R 10, -CN, -C NR 6 R 7, -NR 6 C R 10, -NR 6 S n R 9, -NR 6 S n NR 11 R 12, -NR 6 C OR 8, -NR 6 C NR 11 R 12, -NO 2, -S n NR 6 R 7, oxo, optionally substituted alkyl, -(CH 2) p -optionally substituted cycloalkyl, -(CH 2) m -optionally substituted heterocyclyl, -(CH 2) q -optionally substituted heteroaryl, optionally substituted alkenyl, and optionally substituted alkynyl; R 2 is independently chosen from optionally substituted C 1 -C 6 alkyl, optionally substituted C 1 -C 6 alkoxy, or optionally substituted C 3 -C 8 cycloalkyl; R 3, R 4 are independently chosen from hydrogen, halogen, -CN, or optionally substituted C 1 -C 6 alkyl, R 5 is C 1 -C 6 alkyl, or R 3 and R 5 together with the O atom to which R 5 is attached and the bond there-between form a 5- or 6-membered oxy-containing heterocyclic ring; n is 1 or 2; m, p, q and r are independently chosen from 0, 1, 2, 3, 4, 5, 6; R 6, R 7, R 8, R 9, R 10, R 11 and R 12 are independently selected from hydrogen, alkyl, cycloalkyl, aryl, heteroaryl, heterocyclyl, each of which except for hydrogen, is optionally substituted with one or more substituents independently selected from halo, hydroxyl, mercapto, oxo, alkyl, cycloalkyl, heterocyclyl, optionally substituted amino, and optionally substituted amide, wherein each optionally substituted group above for which the substituent(s) is (are) not specifically designated, can be unsubstituted or independently substituted with one or more, such as one, two or three, substituents independently chosen from C 1 -C 6 alkyl, C 2 -C 6 alkenyl, C 2 -C 6 alkynyl, cycloalkyl, aryl, heterocyclyl, heteroaryl, aryl-C 1 -C 6 alkyl-, heteroaryl-C 1 -C 6 alkyl-, C 1 -C 6 haloalkyl-, -OC 1 -C 6 alkyl, -OC 2 -C 6 alkenyl, -OC 1 -C 6 alkylphenyl, -C 1 -C 6 alkyl-OH, -C 1 -C 6 alkyl-SH, -C 1 -C 6 alkyl-O-C 1 -C 6 alkyl, -OC 1 -C 6 haloalkyl, halo, -OH, mercapto, -NH 2, -C 1 -C 6 alkyl-NH 2, -N(C 1 -C 6 alkyl) 2, -NH(C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl)(C 1 -C 6 alkylphenyl), -NH(C 1 -C 6 alkylphenyl), cyano, nitro, oxo, -C -OH, -C OC 1 -C 6 alkyl, -CON(C 1 -C 6 alkyl) 2, -CONH(C 1 -C 6 alkyl), -CONH 2, -NHC (C 1 -C 6 alkyl), -NHC (phenyl), -N(C 1 -C 6 alkyl)C (C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl)C (phenyl), -C C 1 -C 6 alkyl, -C C 1 -C 6 alkylphenyl, -C C 1 -C 6 haloalkyl, -OC C 1 -C 6 alkyl, -S 2 -C 1 -C 6 alkyl, -S -C 1 -C 6 alkyl, -S 2 -phenyl, -S 2 -C 1 -C 6 haloalkyl, -S 2 NH 2, -S 2 NH(C 1 -C 6 alkyl), -S 2 NH(phenyl), -NHS 2 (C 1 -C 6 alkyl), -NHS 2 (phenyl), and -NHS 2 (C 1 -C 6 haloalkyl). X is CH 2, Y is selected from CH 2, O or S 2; or X and Y together with the bond there-between form -CH=CH- or -C≡C-; G is N or CH; R 1 is aryl or heteroaryl, each of which is optionally substituted with one or more substituents independently selected from halo, -NR 6 R 7, -OR 8, -S n R 9, -(CH 2) r -C R 10, -CN, -C NR 6 R 7, -NR 6 C R 10, -NR 6 S n R 9, -NR 6 S n NR 11 R 12, -NR 6 C OR 8, -NR 6 C NR 11 R 12, -NO 2, -S n NR 6 R 7, oxo, optionally substituted alkyl, -(CH 2) p -optionally substituted cycloalkyl, -(CH 2) m -optionally substituted heterocyclyl, -(CH 2) q -optionally substituted heteroaryl, optionally substituted alkenyl, and optionally substituted alkynyl; R 2 is independently chosen from optionally substituted C 1 -C 6 alkyl, optionally substituted C 1 -C 6 alkoxy, or optionally substituted C 3 -C 8 cycloalkyl; R 3, R 4 are independently chosen from hydrogen, halogen, -CN, or optionally substituted C 1 -C 6 alkyl, R 5 is C 1 -C 6 alkyl, or R 3 and R 5 together with the O atom to which R 5 is attached and the bond there-between form a 5- or 6-membered oxy-containing heterocyclic ring; n is 1 or 2; m, p, q and r are independently chosen from 0, 1, 2, 3, 4, 5, 6; R 6, R 7, R 8, R 9, R 10, R 11 and R 12 are independently selected from hydrogen, alkyl, cycloalkyl, aryl, heteroaryl, heterocyclyl, each of which except for hydrogen, is optionally substituted with one or more substituents independently selected from halo, hydroxyl, mercapto, oxo, alkyl, cycloalkyl, heterocyclyl, optionally substituted amino, and optionally substituted amide, wherein each optionally substituted group above for which the substituent(s) is (are) not specifically designated, can be unsubstituted or independently substituted with one or more, such as one, two or three, substituents independently chosen from C 1 -C 6 alkyl, C 2 -C 6 alkenyl, C 2 -C 6 alkynyl, cycloalkyl, aryl, heterocyclyl, heteroaryl, aryl-C 1 -C 6 alkyl-, heteroaryl-C 1 -C 6 alkyl-, C 1 -C 6 haloalkyl-, -OC 1 -C 6 alkyl, -OC 2 -C 6 alkenyl, -OC 1 -C 6 alkylphenyl, -C 1 -C 6 alkyl-OH, -C 1 -C 6 alkyl-SH, -C 1 -C 6 alkyl-O-C 1 -C 6 alkyl, -OC 1 -C 6 haloalkyl, halo, -OH, mercapto, -NH 2, -C 1 -C 6 alkyl-NH 2, -N(C 1 -C 6 alkyl) 2, -NH(C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl)(C 1 -C 6 alkylphenyl), -NH(C 1 -C 6 alkylphenyl), cyano, nitro, oxo, -C -OH, -C OC 1 -C 6 alkyl, -CON(C 1 -C 6 alkyl) 2, -CONH(C 1 -C 6 alkyl), -CONH 2, -NHC (C 1 -C 6 alkyl), -NHC (phenyl), -N(C 1 -C 6 alkyl)C (C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl)C (phenyl), -C C 1 -C 6 alkyl, -C C 1 -C 6 alkylphenyl, -C C 1 -C 6 haloalkyl, -OC C 1 -C 6 alkyl, -S 2 -C 1 -C 6 alkyl, -S -C 1 -C 6 alkyl, -S 2 -phenyl, -S 2 -C 1 -C 6 haloalkyl, -S 2 NH 2, -S 2 NH(C 1 -C 6 alkyl), -S 2 NH(phenyl), -NHS 2 (C 1 -C 6 alkyl), -NHS 2 (phenyl), and -NHS 2 (C 1 -C 6 haloalkyl).