Created working script some bugs need fixing