Added 2 helper functions to avoid code duplication