implemented factors function