refactor to handle multiple clients on the same page