fixed overlapping and condition calculation