Improving the code a little