making the code more general