Added som functions and changed some structure