Created function and added summary commentary