Cleaned up code for Part4