The present invention relates to heterocyclyl compounds of formula (I), and their pharmaceutically acceptable salts and compositions containing them. The present invention also relates to a process for the preparation of above said novel compounds, and their pharmaceutically acceptable salts. The compounds of formula (I) are useful in the treatment of various disorders that are related to Histamine H3 receptors, for example cognitive disorders, sleep disorders, obesity and pain.