Added function declarations to message handler