Some code has been optimized for readability