Bug Fix for ATPUpdate

Variables cannot be defined as global and have to be given as inputs to
the functions.