separated selection rectangle code