Can you add some short comments describing what the function does and what inputs it takes / outputs it produces?