clean up and improving code