moved and renamed function to aocutils.c