edited function documentation and fixed bug