minor changes to fix issues with the rect being drawn off the screen