refactoring json using respond_with instead of respond_to in each method