Improved utility functions