Added a report function + refactoring.