started cleaning the code and building little functions out of the big ones..