Clean up the logic