Fixed bug with page replacement