code style & refoctored