Duplicated code
Revised to fit new output structure and to use new methods.