Main logic

Now it's working.
Oh, I just forgot to delete this code. It's meaningless.