updated stuff, code cleaner, trying to optimize using trw