adding code provided as part of assignment