Cli python function issue fix

This fix worked for my development and production environment. Have a look and Decide if this works.

## Tested 

* Made several tests in dev/production environment Big improvement!