Make the code more generic