refactored for readability, fixed spelling