4-19: Added more logic to code.