Decoding fixed. Still to refactor