improve code with newest structure