added check prev function