start of work
refactor to be less ugly
scala -> java