code changes and improvements