change a few thing and clean up the code