fix for sparse is valid index