Reimplemented the rectangle selection

Fixed a bug regarding inserting frames