another scipt + fixing minor bugs