I think refactoring is finished, I cant rememeber I still need to fix
the session and cookies
more refactoring