implement decode