added decode with pseudocode