fixed minor errors

head function now supports arrays for JS, still works for single
strings.