made it into a function: