function is now working correctly with multiple parameters. #20 and #21