refactor events controller