CODE CLEANED AND SEPARATED