Improved the utility functions