moved GD library check at the beginning