Corrected bug in parameter parsing. Added function documentation.