refactored function for reading DCT coefficients