Updated LMXRLF with proper end condition