minor changes. finally figures out bug in overlapping logic.