final cleaned code