improving the code