handle json ouput even when request is not XHR
renderer is now selected with accept header
refactoring