Update decodeDetails function

READY TO BE TESTED!