Refactored method

method sendHeaders() was little bit simpliefied