Refactor code + check is connected user