Added a function

Changed out statement and added a function