Made a the function minimising code a script.