Working, need to refactor though
Commented and refactored