Solution for string rotation check