extract parsing of index into own function