code is robuster now