Moved scope function to top of controller
Added shebang
Moved internal functions to bottom (best practice)