Refactor and updates
Added logic for everything