Syntax error in transfer_query function