Added scripts copied from mggimenez and modified