first code to trail values, need refactor