refactor and add test version of click event