move to function
new logic to support different formats
support png
easier to add additional formats
better report