updated detection, rectangle fix