refactored some controller code into services to adhere to a better mvc model