Generalized the code to work with multiple systems