fixed the code based on the comment