made the code more client/server agnostic