fixed assertion and logging