functions.h optimization