refactored away similar functions