changed algorithm to detect guide line