tested and almost working
some changes
some changes