tidied. fudged on jvm