safety first! avoid index out of range issues