made the code slightly clearer and more efficient