Edited reset function and added comments