made method more general for more widespread use