Head and Tail bug fixed