Nice, I think adding a defeat condition was a good choice. Fixing bugs can be very hard, just hang in there and you'll get better at squashin' 'em :)