fixed typo
refactored the code
second commit