Code Organised. Function headers added.