Refactor previous as utility functions