Fix n undefined or empty string for head function