moved function out of callback

was unnecessary and bad formatting