finally getting somewhere (a bit)
refactoring