added some things and some refactor