piece of code was fixed. the automatic_code function was not called before