Added fix for headers already bieng sent out