Moved a general utility function to utils.dart