Moved handlers to global scope