Updated regionA code for general dimensions