Improving code accorditng to the review