moved some funcion inside appropriate classes