implemented loading previous messages when scrolling in a chat window to the top