Final Code with Write up