I have updated the code to fullfill these requirements.