first version of repeted states function