Updated and cleaned code again