Very advanced code that is not realy necessary to make a working script