significant refactor

significant refactor