changed transition detection algorithm