Refactor to generalise