reformatted and cleaned code