Added logic to keep unique rectangles on screen

Checks for mid point of rectangles. Also added functions.