A cleaner pr for cgeo/cgeo#4427

This is a cleaner version of  pr cgeo/cgeo#4427