some changes

cleaned/tested some bits/added function