first working version. checking for bugs.