More efficient method of getting the occupied squares