Total re write! no bugs now!