Refactored utilities for cleaner code