wrapped all callbacks in functions, seemed to work for the first one