Added function and code