Restructured 3body script