modularizing client with help from cmlorenz