updated threads/messages code