fixed beginning and end of input string which were not getting encoded