factors function seems to be working