Finalised refactor