Edited code for readability.