finalized text and made generalized version