Fix typo and use more universal function