added URL encoding to POST function, changed header method to function