Changed to common init method
Refactored controller into a class
Updated some comments