This invention relates to compounds of the formula (I): wherein A, B, R1, R4, m, and n are each as described herein or a pharmaceutically acceptable salt thereof, and compositions containing such compounds and the use of such compounds in the treatment of a condition mediated by 5-HT4 receptor activity such as, but not limited to, gastroesophageal reflux disease, gastrointestinal disease, gastric motility disorder, non-ulcer dyspepsia, functional dyspepsia, irritable bowel syndrome (IBS), constipation, dyspepsia, esophagitis, gastroesophageral disease, nausea, central 10 nervous system disease, Alzheimer's disease, cognitive disorder, emesis, migraine, neurological disease, pain, cardiovascular disorders such as cardiac failure and heart arrhythmia, diabetes and apnea syndrome.