updated some code for clarity