make code more general