Added parameter titlePos to function so that user can specify the position of the title.