refector the code