Improve readability and fully separate declaration and code in listener funcs