added flags to exit on first solution