fix total formatting
fix check for data presense
refactor into multiple packages