A compound of formula (I): or a pharmaceutically acceptable salt thereof or a stereoisomer thereof, wherein, each X 1 , X 2 and X 3 are independently CR 5 or N; ring A is cycloalkyl, aryl, heterocycloalkyl or heteroaryl; R is hydrogen, alkyl or halo; R 1 is R 2 is hydrogen or alkyl; alternatively, R 1 and R 2 together with the nitrogen to which they are attached form a bicyclic heterocyclyl ring optionally containing 1 to 3 additional heteroatoms selected from N, O and S; wherein the bicyclic heterocyclyl ring is optionally substituted by one or more R 6 ; R 3 is hydrogen or alkyl; R 4 at each occurrence independently is hydrogen, halo, haloalkyl, cyano, alkyl, alkenyl, alkynyl, hydroxy, alkoxy, -C(O)R 7 , -alkyl-C(O)R 7 , -S(O) 2 R 7 ; wherein the said alkyl, alkenyl and alkynyl are optionally substituted with 1 to 3 groups selected from hydroxyl, halo, heterocycloalkyl and heteroaryl; alternatively, two R 4 on the same atom together form an oxo (=O) group; R 5 at each occurrence independently is hydrogen, alkyl, halo, haloalkyl or alkoxy; R 6 is alkyl, alkoxy, hydroxy, cyano, halo, or haloalkyl; R 7 is alkyl, hydroxy, alkoxy, -NR e R f , cycloalkyl, aryl, heterocycloalkyl or heteroaryl; wherein each alkyl, cycloalkyl, aryl, heterocycloalkyl and heteroaryl is further optionally substituted by one or more R 6 ; R a and R b each independently are hydrogen or alkyl; R c and R d each independently are hydrogen or alkyl; alternatively R c and R a together represent an oxo (=O) group; R e and R f , each independently are hydrogen or alkyl; alternatively, R e and R f , together with the nitrogen to which they are attached form an optionally substituted 3 to 7 membered heterocyclic ring with 1 to 2 additional heteroatoms selected from N, O and S; wherein the optional substituent is one or more R 6 ; 'm' is an integer from 1 to 3; and 'n' is 0 or 1. each X 1 , X 2 and X 3 are independently CR 5 or N; ring A is cycloalkyl, aryl, heterocycloalkyl or heteroaryl; R is hydrogen, alkyl or halo; R 1 is R 2 is hydrogen or alkyl; alternatively, R 1 and R 2 together with the nitrogen to which they are attached form a bicyclic heterocyclyl ring optionally containing 1 to 3 additional heteroatoms selected from N, O and S; wherein the bicyclic heterocyclyl ring is optionally substituted by one or more R 6 ; R 3 is hydrogen or alkyl; R 4 at each occurrence independently is hydrogen, halo, haloalkyl, cyano, alkyl, alkenyl, alkynyl, hydroxy, alkoxy, -C(O)R 7 , -alkyl-C(O)R 7 , -S(O) 2 R 7 ; wherein the said alkyl, alkenyl and alkynyl are optionally substituted with 1 to 3 groups selected from hydroxyl, halo, heterocycloalkyl and heteroaryl; alternatively, two R 4 on the same atom together form an oxo (=O) group; R 5 at each occurrence independently is hydrogen, alkyl, halo, haloalkyl or alkoxy; R 6 is alkyl, alkoxy, hydroxy, cyano, halo, or haloalkyl; R 7 is alkyl, hydroxy, alkoxy, -NR e R f , cycloalkyl, aryl, heterocycloalkyl or heteroaryl; wherein each alkyl, cycloalkyl, aryl, heterocycloalkyl and heteroaryl is further optionally substituted by one or more R 6 ; R a and R b each independently are hydrogen or alkyl; R c and R d each independently are hydrogen or alkyl; alternatively R c and R a together represent an oxo (=O) group; R e and R f , each independently are hydrogen or alkyl; alternatively, R e and R f , together with the nitrogen to which they are attached form an optionally substituted 3 to 7 membered heterocyclic ring with 1 to 2 additional heteroatoms selected from N, O and S; wherein the optional substituent is one or more R 6 ; 'm' is an integer from 1 to 3; and 'n' is 0 or 1. <EOS>