Theory behind the codes