Add loss condition and I'm sure other things that I forget