substring js bug