adding header validation... fixing bugs