improved the scipt