starting to refactor based on JS pattern