totally fixed and tested region code