add security check of parameters, specifially for buffers