working example
fixed param, added error handling logic