refactor dama decode