refactor into functions, add count
Add formating