added rectangle overlap algorithm