fixed reset issue

changed scope of buff variable , event variable and did dynamic
allocation