moved duplicate content into a function
renamed class