added optimize safe guard