bug fix: moved a function to avoid import errors