Refactored: API to decode one message at a time