updated tracking code as a callable function