Please add this logic in a utility method somewhere.