refactor System.hs to be more generic