Fixed a bug and increased readability