decode function moved into standalone module