moved code from header to cpp