reordering function, still working with websockets