tidied up core