move functions above where first referenced