SPARK-4587: moved codes as before