changed script after problem clarification