Implementation of snake generation