Added functionality to the stub code. Added comments to explain purpose of function