added intersection code, need to add vertical case