fix logic so that all the pages work