Updated Minimal Term function
Updated minimal term function for defensive programming
Changes until now