Cleaned up second solution