bug fix function saveEntity