cleaned code and added resume functionality