completed skeleton of function. need to work out some syntax.