extract variables and client values
bugs correction and begin to clean the code