Cleaned up utility functions