made some refectoring here