updated the code for region selection