merge ws EventListener in one function; code style