removed extra loop, fixed scripts