removed redunant and unsafe code