Clean up logic functions