Add resume option
Clean and make the code simpler