Edited some code for clarity.