bug fixed, forgot to add global declaration to function