added check of input parameters and little documentation