major refactor based on sample