rough draft of full implementation