Isn't it better to pass variables to functions instead of use globals?

Signed-off-by: emanuele <emanuele45@gmail.com>