retrieved loss code
minor fix
fix state bug