Fix API logic