SPARK-4507: moved codes as before