remove and modify some code for safety reasons