move message handling to another js file