call function through object instead of using switch in function.message.js