change max_len of string to size of output buffer
add function description to header
reindent