use index instead of string manipulation