I get the feeling that this function can be shortened, but I\'m not sure what would be the best way to do it. I would like to make the following function more efficient. You