Debugged and cleaned code