added the logic and shizzzzzz