Some code algorithms