Switch to SparseIntArray instead of HashMap for better performance