Fixed reference to inner function in fecthMessages