Eddited update in controller to handle js requests