some refactoring on client file

comments added, lines added/deleted where needed