added states and pagination check