code clean up and simplification.