fixed bug in safe factiry