Refactored and split into controller and model folders