Added more general code