Made some changes mostly for readability