made boxlist a snake object, and reorganized code