moving messageQueue to standard function