Hopefully fixed NameError by moving API calls from controller to model