simplify and format the code