moved sendMessage function to functions.h