Add report logic and refactor a bit