fixed better logic for handeling error pages