finnished tested code works great