Moved logic to server