Add checks for encoding once if separatd by h or w