Edit code and Added most of the side effects needed