Improved code which decides whether to shoot a missile