moved code from header files