snake logic first pass, helper functions added for use in snake logic