Check index is integer before optimising list index