fixed the code and clean it up