moved functions to helper.c