using sendMessage instead of onXX function