refactored data parsing to reduce code size