Creating reusable function