Improved the utility funtions