Revised code based on commit review