added safety  check