tidied up internal