Reorder code
Add shabang
Refactor some code