function to get major