split out client function