fixing the continuity code to check both ends...