refactored. way cleaner