moved duplicate code to header file/object