partial refactor (breaks compile)