Reaftored method

method sendHeaders() was little bit simpliefied