hopefully fixed headers issue and added some error tracking