Added copyright

Rearrange code

Reformat code