add forward-backword decode function