Simplified and clarified selection region creation code