Cleaned up code for delivery