page observer code refactor