simplified code in snake and removed duplicate library