final solution for decoder