use strrchr instead of cycle