continue to add improved code. not finished yet.