fixed AreaSelector bug, refactoried code